#!/bin/bash

function usage()
{
  echo "Usage: app.sh [start|stop|restart|status]"
  exit 1
}

# 开始
function start(){
    path=$1
    if [ -z $path ] ; then
        docker-compose up --no-recreate -d
        exit 1
    fi

    if [ ! -f $path ] ; then
        echo "配置文件不存在"
        exit 1
    fi
    docker-compose -f $path up --no-recreate -d
}

# 停止
function stop(){
    docker-compose stop
}

# 查看状态
function status(){
    docker ps
}

# 重启
function restart() {
  stop
  start
}






case "$1" in
"start")
  start
  ;;
"stop")
  stop
  ;;
"status")
  status
  ;;
"restart")
  restart
  ;;
*)
  usage
  ;;
esac
exit 0


